import { dataimpService } from '~/config/server';
import { NetService } from '~/utils/net.service';
import { Inject, Debounce } from '~/core/decorator';
import { FilterService } from "~/utils/filter.service";

export class LabelingStrategyService {
  @Inject(NetService)
  private netService: NetService;

  /**
   * 打标队列查询
   */
  public queryStrategyConfigPage(data, page) {
    return this.netService.send({
      server: dataimpService.labelingStrategyController.queryLabelingStrategy,
      data:{
        labelName:data.labelName,
        labelStatus:data.labelStatus,
        LatelyDatetimeMin:FilterService.dateRanageFormat(data.checkTime).start,
        LatelyDatetimeMax:FilterService.dateRanageFormat(data.checkTime).end
      },
      page
    });
  }

  /**
   * 保存更新打标队列
   */
  @Debounce()
  public saveLabelingStrategy(data) {
    return this.netService.send({
      server: dataimpService.labelingStrategyController.saveLabelingStrategy,
      data:{
        labelStatus:data.labelStatus,
        labelName:data.labelName,
        formulaJson:data.formulaJson,
        id:data.id
      },
      loading: true
    });
  }
  /**
   * 查询出一条打标队列，用作查看或编辑,通过id
   * @param data
   */
  public getOneById(id) {
    return this.netService.send({
      server:dataimpService.labelingStrategyController.findOneLabelingStrategy,
      data:{
        id
      }
    });
  }
  /**
   * 获取支持的策略字段
   */
  public getLabelFields() {
    return this.netService.send({
      server:dataimpService.labelingStrategyController.getLabelFields
    });
  }

  /**
   * 执行记录查看，根据队列id查询该队列全部汇总记录
   */
  public queryLabelDetailAll(data,page) {
    return this.netService.send({
      server:dataimpService.labelingStrategyController.queryLabelDetailAll,
      data,
      page
    });
  }

  /**
   * 执行记录明细查看
   */
  public queryLabelDetailData(data,page) {
    return this.netService.send({
      server:dataimpService.labelingStrategyController.queryLabelDetailData,
      data,
      page
    });
  }
  /**
   * 获取Label标签数据
   */
  public getLabelNameList() {
    return this.netService.send({
      server: dataimpService.labelingStrategyController.getLabelNameList
    })
  }
  /**
   * 作废/终止
   * @param data 
   */
  public updateLabelStatus(data){
    return this.netService.send({
      server:dataimpService.labelingStrategyController.updateLabelStatus,
      data:{
        id:data.id,
        labelStatus:data.labelStatus
      }
    });
  }
  /**
   * 手动执行催收队列
   */
  public manualLabel() {
    return this.netService.send({
      server: dataimpService.labelingStrategyController.manualLabel,
      // data:{
      //   id:data
      // }
    })
  }
}
